package de.eridea.learning.java.usermanagement.persistence;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "GROUPS")
public class Group {
	@Id
	@GeneratedValue
	private long id;

	@Column(nullable = false)
	String name;

	@ManyToMany(mappedBy = "groups")
	public Set<User> users = new HashSet<User>();

	@ManyToMany(mappedBy = "groups")
	public Set<Resource> resources = new HashSet<Resource>();

	@ManyToOne
	private User owner;

	public long getId() {
		return id;
	}

	private void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public User getOwner() {
		return owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

}
